gh-146250: Fix memory leak in re-initialization of SyntaxError#146251
gh-146250: Fix memory leak in re-initialization of SyntaxError#146251kumaraditya303 merged 6 commits intopython:mainfrom
SyntaxError#146251Conversation
Added `Py_XDECREF`/`Py_XSETREF` to avoid a memory leak when calling `SyntaxError.__init__`.
Misc/NEWS.d/next/Core_and_Builtins/2026-03-21-11-55-16.gh-issue-146250.ahl3O2.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: AN Long <aisk@users.noreply.github.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
|
Sorry about the Py_CLEAR suggestion but I think creating new variables would be cleaner. |
|
What's wrong with using |
|
I think it is just better to hold temp vars and use XSETREF like in |
|
I will test the refleak bots so don't commit anything until they are done! |
|
🤖 New build scheduled with the buildbot fleet by @picnixz for commit 22cff11 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F146251%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again. |
vstinner
left a comment
There was a problem hiding this comment.
LGTM. I confirm that the added test leaks without the fix, and doesn't leak with the fix.
|
Thanks @bkap123 for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
pythonGH-146251) (cherry picked from commit 0de4e08a5990e4692feb1b1ea01c303e468a2894) Co-authored-by: Brij Kapadia <97006829+bkap123@users.noreply.github.com>
|
Sorry, @bkap123 and @kumaraditya303, I could not cleanly backport this to |
|
GH-146517 is a backport of this pull request to the 3.14 branch. |
|
GH-146519 is a backport of this pull request to the 3.13 branch. |
Added
Py_XDECREF/Py_XSETREFto avoid a memory leak when callingSyntaxError.__init__.SyntaxError.__init__memory leak on re-initialization #146250